Skip to content

Reject non-finite look_along directions and fix the camera-convention docs - #90

Merged
bjmorgan merged 4 commits into
mainfrom
feature/look-along-convention
Aug 17, 2026
Merged

Reject non-finite look_along directions and fix the camera-convention docs#90
bjmorgan merged 4 commits into
mainfrom
feature/look-along-convention

Conversation

@bjmorgan

Copy link
Copy Markdown
Owner

Two small corrections to ViewState.look_along.

A direction whose length overflows float64 — for example [1e308, 1e308, 1e308] — previously slipped past the zero-length guard: the norm overflowed to infinity, the forward axis divided to zero, the cross products degenerated, and an all-NaN rotation was assigned silently. Extend the guard to reject a non-finite length (which also catches NaN components), raising a clear error instead. The norm is computed under errstate so the overflow itself does not leak a bare numpy warning alongside the error.

The docstring and inline comment also documented the camera convention backwards, and the summary line contradicted the "looking back towards the origin" line. The tested behaviour is that look_along([0, 0, 1]) gives the identity rotation and a point along the direction projects to positive depth (nearest the viewer), so the direction points out of the screen towards the viewer, with the camera on the +direction side looking back at the origin. The docstring is rewritten so every part agrees; behaviour and the existing tests are unchanged.

Copilot AI lite review requested due to automatic review settings August 17, 2026 10:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

The direction guard left the up vector unchecked: a non-finite up
([nan, ...] or [inf, 0, 0]) produced a silent all-NaN rotation and an
overflowing up ([1e308, ...]) a silent rank-deficient one, the same
failure the direction guard removes.  A zero up raised, but with a
misleading 'parallel to the viewing direction' message.  Guard up
symmetrically (finite and non-zero), leaving the genuine parallel case
to the existing check.
Copilot AI review requested due to automatic review settings August 17, 2026 10:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

- Add a depth-sign test: a point along +direction is nearer the viewer
  than one along -direction, pinning the documented out-of-the-screen
  convention that the existing direction-maps-to-z test (which discards
  depth) leaves unpinned.
- Parametrise the non-finite direction test over NaN and inf components,
  not only the overflowing-norm case.
- Add a zero-direction test for the finite-and-non-zero message.
- Tighten the Raises doc: only a caller-supplied up parallel to the
  direction raises; a default parallel up falls back.
Copilot AI review requested due to automatic review settings August 17, 2026 11:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@bjmorgan
bjmorgan merged commit 81daa2d into main Aug 17, 2026
5 checks passed
@bjmorgan
bjmorgan deleted the feature/look-along-convention branch August 17, 2026 11:06
bjmorgan added a commit that referenced this pull request Aug 17, 2026
Address the PR review:

- Add Oblique.__post_init__ rejecting a non-finite angle and a non-finite
  or negative foreshortening, with a rejection test.  This is the same
  silent-degenerate guard Perspective carries and look_along gained in
  #90: a non-finite parameter otherwise builds a NaN screen matrix that
  poisons every drawn position with an obscure, far-from-cause crash.  A
  foreshortening is the length of a unit step, so negative is rejected;
  angle alone controls the receding direction.
- Test the axes-widget inset factor (the screen matrix's spectral norm --
  1.0 for the non-oblique modes, sqrt(1+f^2) for oblique) and that it
  bounds the sheared tips.
- Correct the screen-frame comments: the projection is not a plain drop
  of z under perspective; the batch's 2D positions come from the
  projected xy, not camera space; the axes comment labelled a
  rotation-only line as also applying the screen matrix.  Note in the ABC
  that screen_matrix is the linear part only and does not reproduce
  to_screen under Perspective.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants